package bingo.portal.service;

import java.util.ArrayList;
import java.util.List;

import net.bingosoft.common.struts.ActionContext;

import bingo.common.annotation.BeanDefination;
import bingo.portal.model.Configuration;
import bingo.portal.model.Menu;
import bingo.portal.model.Portal;

/**
 * Mar 3, 2009 2:19:20 PM PortalManager.java
 * Author:yangdongyu(yangdy@bingosoft.net)
 * ReadMe:
 * ChangeLog:
 */
@BeanDefination
public class PortalManager implements IPortalManager{

	private Portal portal;

	public synchronized Portal getPortal(String princial) {
		if(portal == null){
			portal = new Portal();
			Configuration c = new Configuration();
			portal.setConfiguration(c);
			List<Menu> menus = getMainMenuList(princial);
			portal.setMenuList(menus);
		}
		return portal;
	}



	public String getPrincial() {
		return "QingQing Mother";
	}


	public Configuration getConfiguration() {
		return new Configuration();
	}


	public List<Menu> getChildMenus(String princial, String parentMenuId) {
		String contextPath = ActionContext.getRequest().getContextPath();
		List<Menu> mainMenus = new ArrayList<Menu>();
		Menu m = new Menu();
		m.setId(1L);
		m.setName("Ext 学习");
		m.setTitle("Ext 学习");

		Menu mc = new Menu();
		mc.setId(11L);
		mc.setName("");
		mc.setTitle("extjs 使用示例");
		mc.setUrl(contextPath + "/ext-2.2.1/examples/samples.html");
		m.addChild(mc);
		
		Menu docs = new Menu();
		docs.setId(12L);
		docs.setName("extjs 使用文档");
		docs.setTitle("extjs 使用文档");
		docs.setUrl(contextPath + "/ext-2.2.1/docs/index.html");
		m.addChild(docs);
		
		mainMenus.add(m);

		return mainMenus;
	}


	public List<Menu> getMainMenuList(String princial) {
		List<Menu> mainMenus = new ArrayList<Menu>();
		Menu photos = new Menu();
		photos.setId(1L);
		photos.setName("电子相册");
		photos.setTitle("电子相册");
		photos.setUrl("http://www.baidu.com");
		mainMenus.add(photos);

		Menu m = new Menu();
		m.setId(1L);
		m.setName("电子相册");
		m.setTitle("电子相册");
		m.setUrl("http://www.baidu.com");
		mainMenus.add(m);


		return mainMenus;
	}



}
